package net.oschina.app.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import net.oschina.app.MApp;
import net.oschina.app.R;

import java.util.List;

/**
 * Created by huang on 2017-4-2.
 */

public class EventsPagerAdapter extends FragmentStatePagerAdapter{
    List<Fragment> mdata;

    public EventsPagerAdapter(FragmentManager fm, List<Fragment> data) {
        super(fm);
        this.mdata = data;
    }

    @Override
    public Fragment getItem(int position) {
        return mdata.get(position);
    }

    @Override
    public int getCount() {
        return mdata.size();
    }

    //返回TabLayout的标题字符串
    @Override
    public CharSequence getPageTitle(int position) {
        return MApp.mContext.getResources().getStringArray(R.array.events)[position];
    }
}
